package cn.swing.his.finance.webapi.controller;

import cn.swing.his.common.web.JsonResult;
import cn.swing.his.finance.service.IPrescriptionService;
import cn.swing.his.finance.webapi.service.impl.PrescriptionServiceImpl;
import cn.swing.his.pojo.finance.vo.PrescriptionVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("prescription")
@Api(tags = "药品明细模块")
@Slf4j
public class PrescriptionController {
    @Autowired
    private IPrescriptionService prescriptionService;

    @GetMapping("/updateState")
    public JsonResult<Void> updateState(Integer patientId){
        prescriptionService.updateMedicineById(patientId);
        return JsonResult.ok();
    }

    @GetMapping("/list")
    @ApiOperation("根据就诊号获取当前药品数据")
    public JsonResult<List<PrescriptionVO>> PrescriptionListByPatientId(Integer id){
        System.out.println("patientId:"+id);
        List<PrescriptionVO> list=prescriptionService.selectPrescriptionByPatientId(id);
        for (PrescriptionVO p:list) {
            System.out.println(p);
        }
        return JsonResult.ok(list);
    }
}
